package com.example.kcp.net;

import io.vertx.core.Vertx;
import io.vertx.core.datagram.DatagramSocket;
import io.vertx.core.datagram.DatagramSocketOptions;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @author "陈凯航"
 * @date 2024/9/23
 * @mail "mengxingcn@aliyun.com"
 */
@Component
@RequiredArgsConstructor
public class UdpClient implements InitializingBean {
    private final Vertx vertx;
    private static final ConcurrentHashMap<String, DatagramSocket> MAP = new ConcurrentHashMap<>();

    @Override
    public void afterPropertiesSet() throws Exception {
        DatagramSocketOptions options = new DatagramSocketOptions();
        DatagramSocket datagramSocket = vertx.createDatagramSocket(options);

        MAP.put("123", datagramSocket);
    }

}
